/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
void reverse(struct TreeNode* root, int* K,int*p)
{
    if(root)
    {
        reverse(root->right,K,p);
        if((*K)--==1)
        *p=root->val;
        reverse(root->left,K,p);
    }

}
int kthLargest(struct TreeNode* root, int k)
{
    int a=0;
    reverse(root,&k,&a);
    return a;
    
}